﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace ReporterSystem
{
    internal class cifRequest
    {
        // Fields
        private ArrayList m_aTypes = new ArrayList();
        private bool m_bExportingAllFields;
        private bool m_bGeneratingExtensions;
        private bool m_bImages;
        private bool m_bLocalInvariant;
        private bool m_bQualifiedNames;
        private bool m_bRawNumbers;
        private string m_strImageFormat = "";
        private string m_strImageTarget = "";
        private string m_strResultFile = "";
        private string m_strTransform = "";

        // Methods
        public void AddType(string strType)
        {
            this.m_aTypes.Add(strType);
        }

        public bool Generate(string strOutput)
        {
            XmlWriter writer = new XmlTextWriter(strOutput, null);
            writer.WriteStartDocument();
            writer.WriteStartElement("cifRequest");
            writer.WriteAttributeString("layer", "presentation");
            if (this.m_bRawNumbers)
            {
                writer.WriteAttributeString("rawNumbers", "true");
            }
            if (this.m_bLocalInvariant)
            {
                writer.WriteAttributeString("localInvariant", "true");
            }
            if (this.m_bQualifiedNames)
            {
                writer.WriteAttributeString("qualifiedNames", "true");
            }
            if (this.m_bImages)
            {
                writer.WriteAttributeString("images", "true");
                writer.WriteStartElement("imageFormat");
                writer.WriteString(this.m_strImageFormat);
                writer.WriteEndElement();
                writer.WriteStartElement("imageTarget");
                writer.WriteString(this.m_strImageTarget);
                writer.WriteEndElement();
            }
            writer.WriteStartElement("target");
            writer.WriteAttributeString("file", this.m_strResultFile);
            writer.WriteEndElement();
            if (!this.m_strTransform.Equals(""))
            {
                writer.WriteStartElement("transform");
                writer.WriteAttributeString("file", this.m_strTransform);
                writer.WriteEndElement();
            }
            if (this.m_aTypes.Count > 0)
            {
                writer.WriteStartElement("notebook");
                foreach (string str in this.m_aTypes)
                {
                    writer.WriteStartElement(str);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
            return true;
        }

        // Properties
        public bool ExportingAllFields
        {
            get
            {
                return this.m_bExportingAllFields;
            }
            set
            {
                this.m_bExportingAllFields = value;
            }
        }

        public bool GeneratingExtensions
        {
            get
            {
                return this.m_bGeneratingExtensions;
            }
            set
            {
                this.m_bGeneratingExtensions = value;
            }
        }

        public string ImageFormat
        {
            get
            {
                return this.m_strImageFormat;
            }
            set
            {
                this.m_strImageFormat = value;
            }
        }

        public bool Images
        {
            get
            {
                return this.m_bImages;
            }
            set
            {
                this.m_bImages = value;
            }
        }

        public string ImageTarget
        {
            get
            {
                return this.m_strImageTarget;
            }
            set
            {
                this.m_strImageTarget = value;
            }
        }

        public bool LocalInvariant
        {
            get
            {
                return this.m_bLocalInvariant;
            }
            set
            {
                this.m_bLocalInvariant = value;
            }
        }

        public bool QualifiedNames
        {
            get
            {
                return this.m_bQualifiedNames;
            }
            set
            {
                this.m_bQualifiedNames = value;
            }
        }

        public bool RawNumbers
        {
            get
            {
                return this.m_bRawNumbers;
            }
            set
            {
                this.m_bRawNumbers = value;
            }
        }

        public string ResultFile
        {
            get
            {
                return this.m_strResultFile;
            }
            set
            {
                this.m_strResultFile = value;
            }
        }

        public string Transform
        {
            get
            {
                return this.m_strTransform;
            }
            set
            {
                this.m_strTransform = value;
            }
        }
    }
}
